From 6c2769adcf6b1058aa382d7ae6a9e9d60e3a1e3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 8 Jul 2018 22:38:25 +0200 Subject: [PATCH] babl: export symbol babl_space_to_icc --- babl/babl-icc.c | 18 +++++++++++------- babl/babl-internal.h | 18 ------------------ babl/babl.h | 19 +++++++++++++++++++ export-symbols | 1 + 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/babl/babl-icc.c b/babl/babl-icc.c index 918b81e..ed6e0cc 100644 --- a/babl/babl-icc.c +++ b/babl/babl-icc.c @@ -484,14 +484,14 @@ switch (trc->type) static void symmetry_test (ICC *state); -const char *babl_space_to_icc (const Babl *babl, - const char *description, - const char *copyright, - BablICCFlags flags, - int *ret_length) +char *babl_space_to_icc (const Babl *babl, + const char *description, + const char *copyright, + BablICCFlags flags, + int *ret_length) { const BablSpace *space = &babl->space; - static char icc[65536]; + char icc[65536]; int length=65535; ICC *state = icc_state_new (icc, length, 10); @@ -606,7 +606,11 @@ const char *babl_space_to_icc (const Babl *babl, *ret_length = length; babl_free (state); - return icc; + { + char *ret = malloc (length); + memcpy (ret, icc, length); + return ret; + } } diff --git a/babl/babl-internal.h b/babl/babl-internal.h index 8645f90..2a0094d 100644 --- a/babl/babl-internal.h +++ b/babl/babl-internal.h @@ -410,25 +410,7 @@ int _babl_file_get_contents (const char *path, long *length, void *error); -typedef enum { - BABL_ICC_DEFAULTS = 0, - BABL_ICC_COMPACT_TRC_LUT = 1, -} BablICCFlags; -/* babl_space_to_icc: - * - * Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to - * be as small and compact as possible, TRCs are stored as 1024 entry LUT(s). - * - * you should make a copy of the profile before making another call to this - * function. - */ - -const char *babl_space_to_icc (const Babl *space, - const char *description, - const char *copyright, - BablICCFlags flags, - int *icc_length); /* babl_space_get_rgbtoxyz: diff --git a/babl/babl.h b/babl/babl.h index 1d7d433..f6ba782 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -488,6 +488,25 @@ const Babl * babl_trc_gamma (double gamma); */ const Babl * babl_trc (const char *name); +typedef enum { + BABL_ICC_DEFAULTS = 0, + BABL_ICC_COMPACT_TRC_LUT = 1, +} BablICCFlags; + +/* babl_space_to_icc: + * + * Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to + * be as small and compact as possible, TRCs are stored as 1024 entry LUT(s). + * + * the result is allocated with malloc and you should free it when done. + */ + +char *babl_space_to_icc (const Babl *space, + const char *description, + const char *copyright, + BablICCFlags flags, + int *icc_length); + #ifdef __cplusplus } #endif diff --git a/export-symbols b/export-symbols index 952aeb6..28c1851 100644 --- a/export-symbols +++ b/export-symbols @@ -41,6 +41,7 @@ babl_sampling babl_set_user_data babl_space babl_space_from_xyz +babl_space_to_icc babl_chromaticities_make_space babl_space_get_rgbtoxyz babl_space_to_xyz -- 2.30.2